<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
   xmlns:f="http://xmlns.jcp.org/jsf/core"
   xmlns:h="http://xmlns.jcp.org/jsf/html"
   xmlns:p="http://primefaces.org/ui"
   xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
   template="/WEB-INF/templates/business/buyer/template.xhtml">
   
   	<f:metadata>
	   	<f:viewParam name="bulletinId" value="#{bulletinHome3.id}"></f:viewParam>
	   	<f:event listener="#{bulletinHome3.initConversation()}" type="preRenderView"></f:event>
   	</f:metadata>
	   <ui:define name="supplier_head">
		   <style type="text/css">
				.label {
					width:120px;
					line-height:30px;	
					color: #333;
					text-align: right;
					padding-right:20px;
					text-align: right;
				}
				
				.value {
					font-style:normal;
					font-size: 16px;
					line-height:30px;
					color:#666666;				
					text-align:left;
					padding-left:20px;
				}
	   		</style>
	   </ui:define>
   	<ui:define name="buyer_content">
   
		<h:form id="editForm">
			<p:panel id="panel" header="申请结算" style="margin-bottom:10px;">
		       	<p:messages id="messages" closable="true">
		       		<p:autoUpdate />
		       	</p:messages>
		        <ui:include src="/WEB-INF/templates/business/bulletinBasicInfo.xhtml" />
			</p:panel>
			
			<p:commandButton value="申请" oncomplete="PF('applyingTradeDoneDialog').show();" immediate="true" />
			<p:commandButton action="#{tradeHome.cancel()}" value="取消" immediate="true"></p:commandButton>
		</h:form>
		
		<p:dialog id="tradedDialog" 
			header="结算"
		   widgetVar="applyingTradeDoneDialog"
		   	   width="640"
		   	  height="480"
		   	   modal="true">
		   	<h:form id="applyForm">
		   		<p:panel style="margin-top:20px;">
		   			<p:outputLabel for="price" value="结算服务金额" style="margin:10px;"></p:outputLabel>
		   			<p:inputNumber id="price" value="#{bulletinHome3.instance.applyDonePrice}" required="true" decimalPlaces="2" />
					<br/>
					<p:outputLabel for="attachments" value="附件材料" style="margin:10px;"/>		
					<p:outputPanel id="attachments">
						<p:fileUpload
							id="attachmentUploadFile"
							label="选择"
							mode="advanced"
							multiple="true"
							skinSimple="true"
							sizeLimit="#{1024 * 1024 * 3}"
							uploadLabel="上传"
							cancelLabel="取消"
							update="applyForm:uploadedAttachments"
							fileUploadListener="#{bulletinHome3.uploadAppliedDoneAttachment}"
						/>
						<p:panel id="uploadedAttachments">
							<ul>
								<p:repeat var="_attachment" value="#{bulletinHome3.instance.appliedDoneAttachments}" varStatus="_status">
									<li>
										<h:outputText value="#{_attachment.filename}" />
										<span>
											<p:commandLink styleClass="closeBtn" action="#{bulletinHome3.removeAppliedDoneAttachment(_attachment)}" update="applyForm:uploadedAttachments" immediate="true"  ></p:commandLink>		
											<p:commandButton style="margin-left:10px;" ajax="false"  icon="ui-icon-arrowthick-1-s">
										        <p:fileDownload value="#{fileDownloadView.download(_attachment)}" />
										    </p:commandButton>		
										</span>
									</li>
								</p:repeat>
							</ul>
						</p:panel>
					</p:outputPanel>
					
					<f:facet name="footer">
						<p:commandButton value="结算" action="#{bulletinHome3.applingDone()}" oncomplete="PF('applyingTradeDoneDialog').hide();"  />
						<p:commandButton value="取消" action="#{bulletinHome3.cancel()}" oncomplete="PF('applyingTradeDoneDialog').hide();" immediate="true" />
					</f:facet>
		   		</p:panel>
						
						
			</h:form>			
		</p:dialog>
      
   	</ui:define>
</ui:composition>
